package com.nbsaas.boot.manufacturing.rest.resource;

import com.nbsaas.boot.manufacturing.api.apis.MaterialApi;
import com.nbsaas.boot.manufacturing.data.entity.Material;
import com.nbsaas.boot.manufacturing.api.domain.request.MaterialRequest;
import com.nbsaas.boot.manufacturing.api.domain.response.MaterialResponse;
import com.nbsaas.boot.manufacturing.api.domain.simple.MaterialSimple;
import com.nbsaas.boot.manufacturing.rest.convert.MaterialSimpleConvert;
import com.nbsaas.boot.manufacturing.rest.convert.MaterialEntityConvert;
import com.nbsaas.boot.manufacturing.rest.convert.MaterialResponseConvert;
import com.nbsaas.boot.manufacturing.data.repository.MaterialRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   物料-业务接口实现
*/
@Transactional
@Service
public class MaterialResource extends BaseResource<Material,MaterialResponse, MaterialSimple, MaterialRequest>  implements MaterialApi {

    @Resource
    private MaterialRepository materialRepository;

    @Override
    public JpaRepositoryImplementation<Material, Serializable> getJpaRepository() {
        return materialRepository;
    }

    @Override
    public Function<Material, MaterialSimple> getConvertSimple() {
        return new MaterialSimpleConvert();
    }

    @Override
    public Function<MaterialRequest, Material> getConvertForm() {
        return new MaterialEntityConvert();
    }

    @Override
    public Function<Material, MaterialResponse> getConvertResponse() {
        return new MaterialResponseConvert();
    }




}


